<script type="text/javascript">
    var enable_submit = true;
    function submit_rrserver_create() {
        var rrserver_address = $("#rrserver_modal").find("#rrserver_address_cr");
        var rrserver_port = $("#rrserver_modal").find("#rrserver_port_cr");
        var bValid = true;
        bValid = bValid && checkipRegexp(rrserver_address, /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/i, "无效的IP地址.");
        bValid = bValid && checkRegexp_num(rrserver_port, /^[0-9]+$/i, "端口必须为大于0的整数");
        bValid = bValid && checkPort(rrserver_port, '端口范围为 1 ～ 65535。');
        if (bValid) {
            $(".table .error_tip").hide();
            if (enable_submit) {
                enable_submit = false;
                var $submitBtn = $('.modal-footer').find('.btn-blue');
                $submitBtn.html('<i class="fa fa-spinner fa-spin" style="margin:3px 6px;"></i>');
                $('.rtn-tip').slideUp('fast');
                $.post("/rrserver_create", {
                        "address": $.trim(rrserver_address.val()),
                        "port": $.trim(rrserver_port.val()),
                    },
                    function (data) {
                        if (data.reply.is_success) {
                            angular.element('#rrserver_controller').scope().close();
                            $('#rrserver_table').trigger("reloadGrid")
                        } else {
                            error = data.reply.error;
                            $('.rtn-tip').text(error).slideDown('fast');
                            $submitBtn.html(SelfTranslate("[[ 'label ok'|translate ]]"));
                            enable_submit = true;
                        }
                    });
            }
        }
    }
    $(function() {
        var obj = {
            'address':'输入ip地址。',
            'port':'端口范围为 1 ～ 65535。',
        }
        bindMouseEvent('#rrserver_modal', obj);
        /* 为小图标绑定鼠标移入移出事件结束 */
    });
</script>
<div class="modal-header">
    <h3>创建站点</h3>
</div>
<div class="modal-body modal-body-height" id="rrserver_modal">
    <div class="user-create-box">
        <div class="rtn-tip"></div>
        <table class="super-info" style="margin-top:0; ">
            <tr>
                <td>
                    <label>IP</label><a>*</a>
                </td>
                <td>
                    <input id="rrserver_address_cr" name="rrserver_address_cr" size="25" type="text"/>
                    <i class="fa fa-question-circle" itype="address"></i>
                </td>
                <td><label>端口</label><a>*</a></td>
                <td>
                    <input id="rrserver_port_cr" name="rrserver_port_cr" size="25" type="text"/>
                    <i class="fa fa-question-circle" itype="port"></i>
                </td>
            </tr>
        </table>
    </div>
    <div class="error-tip">
        <p></p>
        <span></span></div>
    <div class="tip">
        <p></p>
        <span></span></div>
</div>
<div class="modal-footer">
    <button class="btn btn-blue" ng-click="ok()">[[ 'label ok'|translate ]]</button>
    <button class="btn btn-white" ng-click="cancel()">[[ 'label cancel'|translate ]]</button>
</div>
